﻿using pub.CmdUI.Cmd;
using pub.CmdUI.UI.Control;

namespace todo.Cmd.View
{
    public class ShowDoneItemsCmd : DefaultCmd, ICmdState
    {
        bool? ICmdState.Checked
        {
            get { return App.Settings.DoneItemsVisible; }
        }

        public override void Execute(IControlUI controlUi)
        {
            var doneItemsVisible = !App.Settings.DoneItemsVisible;
            App.MainForm.Www.Document.InvokeScript("setDoneItemsVisible",
                    new object[] {doneItemsVisible});
            App.Settings.DoneItemsVisible = doneItemsVisible;
        }
    }
}